﻿function findComputerInfoCallback(data) {
    data = JSON.parse(data);
    $("#msg").html('')
    for (var p in data) {
        $("#msg").append($("<li class='list-group-item'>" + p + ", " + data[p] + "</li>"));
    }
};

function findComputerResourceUsageCallback(data) {
    data = JSON.parse(data);
    $("#msg").html('');
    for (var p in data) {
        $("#msg").append($("<li class='list-group-item'>" + p + ", " + data[p] + "</li>"));
    }
};

function findUsbDevicesCallback(data) {
    data = JSON.parse(data);
    $("#msg").html('');
    data.forEach(function(ni) {
        $("#msg")
        
            .append($("<li class='list-group-item'>" + ni.DeviceID + ", " + ni.PNPDeviceID + ', ' + ni.MSDescription + "</li>"));
    })
};

function readIdCardInfoCallback(data) {
    data = JSON.parse(data);
    $("#msg").html('');
    for (var p in data) {
        if (p === 'PhotoBase64') {
            $("#msg").append($("<li class='list-group-item'><img src='" + data[p] + "' alt='" + p + "'/></li>"));
        } else {
            $("#msg").append($("<li class='list-group-item'>" + p + ", " + data[p] + "</li>"));
        }
    }
    //$("#msg").html(JSON.stringify(data));
};
function showReportFormCallback(data) {
    data = JSON.parse(data);
    //$("#msg").html('');
    console.log(data);
    //$("#msg").html(JSON.stringify(data));
};

function findComputerInfo() {
    dotNet.findComputerInfo(findComputerInfoCallback);
};

function findComputerResourceUsage() {
    dotNet.findComputerResourceUsage(findComputerResourceUsageCallback);
};

function findUsbDevices() {
    dotNet.findUsbDevices(findUsbDevicesCallback);
};

function readIdCardInfo() {
    dotNet.readIdCardInfo(readIdCardInfoCallback);
};

function readIcCardInfo() {
    dotNet.readIcCardInfo(readIdCardInfoCallback);
};

function wirteIcCard() {
    dotNet.myProperty = prompt("请输入10个字符以内的文本");
    dotNet.wirteIcCard(readIdCardInfoCallback);
};
function showReportForm() {
    dotNet.myProperty = prompt("请输入报表");
    dotNet.showReportForm(showReportFormCallback);
};